<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">

	$("#uploadImage").click(function(){
	  /*  $("#uploadImage").addClass('hidden'); */
		var btn = this;
		var programId = $("input[name=id]").val();			
		if ($("#file").val().length == 0) {
			alert("请选择图片");
			return;
			}
		var filepath=$("#file").val();
		var extStart=filepath.lastIndexOf(".");
		  var ext=filepath.substring(extStart,filepath.length).toUpperCase();
		  if(ext!=".PNG"&&ext!=".JPG"){
            alert("上传图片格式必须为  PNG  JPG ");
            return;
		   }
		   var imageres=validateImageSize($("#file"),512);
		   if(!imageres){
			   alert("图片不能大于0.5M");
			   return;
		   }

		  $("#uploadImage").addClass('hidden');
		 $.ajaxFileUpload({
	        url: [[@{/xxxxxx/xxxxx/xxxx}]],
	        type: 'post',
	        secureuri: false,
	        fileElementId: 'file',
	        dataType: 'text',
	        data:{program_id:program_id},
	        success: function (data,status){
	        	$("#uploadImage").removeClass('hidden');
	        	var data2=eval('(' + data + ')');
	        	var data1=	data2["data"];
	        	var result=data2["success"];
	        	var message=data2["message"];
	        	if (result=="false") {
	        	   message="海报上传失败";
	        	} else {
	        	   $('#file').val('');
	        	   message="海报上传成功";
	        	}
		        $("#message").html(message);
	        }
       }); 
		
	 });


</script>
</head>
<body>
           <div class="row page-heading">
	                               <div class="col-sm-8">
										<p>上传本地海报:</p>
										<input type="file" name="file" id="file" style="display:inline-block"/>
										<span id="uploadImage" class="btn btn-default btn-sm">上传</span>
	                            	</div>
	          </div>
</body>
</html>